using System;
using System.ComponentModel.DataAnnotations;
using Localization;
using SinBiota.Model.Entities.CustomAttributes;

namespace SinBiota.Model.Entities
{
    [LocalizedName("Location", NameResourceType = typeof(Strings))]
    public class Location : BaseEntity
    {
        [LocalizedName("ConservationUnit", NameResourceType = typeof(Strings))]
        public virtual ConservationUnit ConservationUnit { get; set; }

        [LocalizedName("Municipality", NameResourceType = typeof(Strings))]
        public virtual Municipality Municipality { get; set; }

        [LocalizedName("DrainageBasin", NameResourceType = typeof(Strings))]
        public virtual DrainageBasin DrainageBasin { get; set; }

        [LocalizedName("Ambient", NameResourceType = typeof(Strings))]
        public virtual Ambient Ambient { get; set; }

        [LocalizedName("Description", NameResourceType = typeof(Strings))]
        public virtual string Description { get; set; }

        [LocalizedName("Latitude", NameResourceType = typeof(Strings))]
        [Required(ErrorMessageResourceType = typeof(Messages), ErrorMessageResourceName = "FieldCannotBeEmpty")]
        public virtual double Latitude { get; set; }

        [LocalizedName("Longitude", NameResourceType = typeof(Strings))]
        [Required(ErrorMessageResourceType = typeof(Messages), ErrorMessageResourceName = "FieldCannotBeEmpty")]
        public virtual double Longitude { get; set; }

        [LocalizedName("LocationExtension", NameResourceType = typeof(Strings))]
        public virtual String LocationExtension { get; set; }

        [LocalizedName("LocationExtensionUnit", NameResourceType = typeof(Strings))]
        public virtual LocationExtensionUnit LocationExtensionUnit { get; set; }

        [LocalizedName("LocationPrecision", NameResourceType = typeof(Strings))]
        public virtual LocationPrecision LocationPrecision { get; set; }

        // Do we need properties to save original data: UTMX, UTMY, UTM_ZONE, COORD_TYPE, LAT, LONG (Graus-Min-Seg)?? 

        [LocalizedName("GPSPrecision", NameResourceType = typeof(Strings))]
        public virtual float GPSPrecision { get; set; }

        public virtual string FullLocation
        {
            get
            {
                return String.Format("{0}{1}", Municipality == null ? "" : Municipality.Name, !string.IsNullOrEmpty(Description) ? ", " + Description : "");
            }
        }
    }
    // Properties: Enumerations 

    public enum LocationPrecision
    {
        Locality, Municipality, OccurrenceArea, OccurrencePoint, ConservationUnit
    }

    public enum Ambient
    {
        Terrestrial, Freshwater, Marine
    }
    public enum LocationExtensionUnit
    {
        m , m2 , m3 , kg , km , km2 , ha 
    }
}
